define(['zepto.min.js'],function(require, exports, module){
	var toastTimeOut;
	(function(){
		$('body').append('<div id="loading_mask"></div>');
		$('body').append('<div id="loading_dialog"><div id="loading_icons"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div></div>');
		$('body').append('<div id="loading_page_mask"></div>');
		$('body').append('<div id="loading_page_dialog"><div id="loading_page_icons"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div></div>');
	})();
	var exports = {
			loadOpt:function(open){//显示/隐藏操作加载框
				if(open){
					$('#loading_mask,#loading_dialog').css('display','block');
					$('#loading_icons').addClass('ball-spin-fade-loader');
					$('#loading_dialog').css({'top':($(window).height()-$('#loading_dialog').height())/2+'px','left':($(window).width()-$('#loading_dialog').width())/2+'px',})
				}else{
					$('#loading_mask,#loading_dialog').css('display','none');
					$('#loading_icons').removeClass('ball-spin-fade-loader');
				}
			},
			loadPage:function(open){//显示/隐藏页面加载框
				if(open){
					$('#loading_page_mask,#loading_page_dialog').css('display','block');
					$('#loading_page_icons').addClass('ball-spin-fade-loader loader_bg');
					$('#loading_page_dialog').css({'top':($(window).height()-$('#loading_page_dialog').height())/2+'px','left':($(window).width()-$('#loading_page_dialog').width())/2+'px',})
				}else{
					$('#loading_page_mask,#loading_page_dialog').css('display','none');
					$('#loading_page_icons').removeClass('ball-spin-fade-loader loader_bg');
				}
			},
			loadNullData:function($obj,content){
				//alert($obj.parent().find('.nullIcon').html());
				$obj.parent().find('.nullIcon').remove();
				var nullData=$('<div style="margin-top: 35%;text-align: center;" class="nullIcon"><img style="width:90px" src="images/icons/nullIcon.png" /><div>'+content+'</div></div>');
				var len=$obj.children().length;
				if(len==0){
					$obj.parent().append(nullData);
					//$obj.parent().find('#pull_pullDown').hide();
					$obj.parent().find('#pull_pullUp').hide();
				}else{
					$obj.parent().find('.nullIcon').remove();
					//$obj.parent().find('#pull_pullDown').show();
					$obj.parent().find('#pull_pullUp').show();
				}
		    },
			tip:function(conf){//提示框
				var config={
					title:'提示',
					txt:'错误提示',
					ok:'我知道了',
					callback:null
				};
				$.extend(config, conf);
				$('body').append('<div id="alert_mask"></div>'+
					'<div id="alert_box">'+
						'<div id="alert_title">'+config.title+'</div>'+
						'<div id="alert_txt">'+config.txt+'</div>'+
						'<div id="alert_ok">'+config.ok+'</div>'+
					'</div>');
				$('#alert_box').css('top',($(window).height()-$('#alert_box').height())/2+'px').addClass('bounceIn');
				$('#alert_ok').click(function(){
					$('#alert_mask,#alert_box').remove();
					if(config.callback){
						config.callback();
					}
				});
			},
			confirm:function(conf){
				var config={
					title:'温馨提示',
					txt:'提示内容',
					ok:null,
					cancle:null
				};
				$.extend(config, conf);
				$('body').append('<div id="alert_mask"></div>'+
					'<div id="alert_box">'+
						'<div id="alert_title">'+config.title+'</div>'+
						'<div id="alert_txt">'+config.txt+'</div>'+
						'<div id="alert_confirm">确定</div>'+
						'<div id="alert_cancle">取消</div>'+
					'</div>');
				$('#alert_confirm,#alert_cancle').width(($('#alert_box').width()-1)/2);
				$('#alert_box').css('top',($(window).height()-$('#alert_box').height())/2+'px').addClass('bounceIn');
				$('#alert_confirm').click(function(){
					$('#alert_mask,#alert_box').remove();
					if(config.ok){
						config.ok();
					}
				});
				$('#alert_cancle').click(function(){
					$('#alert_mask,#alert_box').remove();
					if(config.cancle){
						config.cancle();
					}
				});
			},
			confirmInput:function(conf){
				var config={
					title:'提示标题',
					txt:'提示内容',
					ok:null,
					cancle:null
				};
				$.extend(config, conf);
				$('body').append('<div id="alert_mask"></div>'+
					'<div id="alert_box">'+
						'<div id="alert_title">'+config.title+'</div>'+
						'<div id="alert_txt"><input type="text" placeholder="'+config.txt+'"/></div>'+
						'<div id="alert_confirm">确定</div>'+
						'<div id="alert_cancle">取消</div>'+
					'</div>');
				$('#alert_confirm,#alert_cancle').width(($('#alert_box').width()-1)/2);
				$('#alert_box').css('top',($(window).height()-$('#alert_box').height())/2+'px').addClass('bounceIn');
				$('#alert_confirm').click(function(){
					if(config.ok){
						config.ok($('#alert_txt input').val());
					}
					$('#alert_mask,#alert_box').remove();
				});
				$('#alert_cancle').click(function(){
					if(config.cancle){
						config.cancle($('#alert_txt input').val());
					}
					$('#alert_mask,#alert_box').remove();
				});
			},
			okCancle:function(params){
				var config={
					txt:'确定/取消？',
					okTxt:'确定',
					cancleTxt:'取消',
					ok:null,
					cancle:null
				};
				$.extend(config,params);
				$('body').append('<div id="confirm-box">'+
						'<div class="confirm-mask"></div>'+
						'<div class="confirm confirmUp">'+
							'<div class="confirm-txt">'+config.txt+'</div>'+
							'<div class="ok">'+config.okTxt+'</div>'+
							'<div class="cancle">'+config.cancleTxt+'</div>'+
						'</div>'+
				'</div>');
				$('#confirm-box .ok').click(function(){
					$('.confirm').removeClass('confirmUp').addClass('confirmDown');
					$('.confirm-mask').remove()
					setTimeout(function(){
						$('#confirm-box').remove();
					},300);
					if(config.ok){
						config.ok();
					}
				});
				$('#confirm-box .cancle,#confirm-box .confirm-mask').click(function(){
					$('.confirm').removeClass('confirmUp').addClass('confirmDown');
					$('.confirm-mask').remove()
					setTimeout(function(){
						$('#confirm-box').remove();
					},300);
					if(config.cancle){
						config.cancle();
					}
				});
			},
			toast:function(flag,msg,callback){
				$('.messge-box').remove();
				$('#message_mask').remove();
				clearTimeout(toastTimeOut);
				$('body').prepend('<div id="message_mask"></div><div class="messge-box bounceIn"><div class="message-mark"></div><div class="messge-box-icon"><i class="message-toast-icon"></i></div><div class="messge-box-content"></div></div>');
				$('.messge-box').css('left',($(window).width()-180)/2+'px');
				$('.messge-box').css('top',($(window).height()-110)/2+'px');
				$('.messge-box-content').html(msg.toString());
				$('.message-toast-icon').addClass(flag?'succee-icon':'info-icon');
				toastTimeOut=setTimeout(function(){
					$('.messge-box').removeClass('bounceIn').fadeOut(function(){
						$('.messge-box').remove();
						$('#message_mask').remove();
					});
					if(callback){callback();}
				},1500);
				$('#message_mask').click(function(){
					clearTimeout(toastTimeOut);
					$('.messge-box').removeClass('bounceIn').fadeOut(function(){
						$('.messge-box').remove();
						$('#message_mask').remove();
					});	
					if(callback){callback();}
				});
			},
			initSelect:function(params){
				var config={
					selector:$('#select'),
					selectArray:new Array(),
					callback:null
				};
				$.extend(config, params);
				config.selector.click(function(event){
					event.stopPropagation();
					$('#select_mask,#select_picker').remove();
					$('body').append('<div id="select_mask"></div><div id="select_picker" class="selectUp"><div id="select_header"><div id="select_cancle"></div><div id="select_ok">完成</div></div><div id="select_body"><div id="select_top"></div><div id="select_fotter"></div></div></div>');
					$('#select_body').append('<div id="select_wrapper"><div><div class="m_select"></div><div class="m_select"></div><div class="m_select end_select"></div><div class="m_select"></div><div class="m_select"></div></div></div>');
					$('#select_wrapper').height(240);
					$(config.selectArray).each(function(){
						$('<div class="m_select">'+this+'</div>').insertBefore('.end_select');
					});
					var select_scroll=new iScroll('select_wrapper',{scrollbarClass: 'myScrollbar',bounce:false,snap: 'div'});
					var index=config.selector.html()=="" || config.selector.html()==null?0:config.selectArray.indexOf(config.selector.html());
					select_scroll.scrollTo(0,-index*40,0);
					$('#select_ok').click(function(){
						index=-select_scroll.y/40;
						if(config.callback){
							config.callback(config.selectArray[index]);
						}
						$('#select_cancle').click();
					});
					$('#select_cancle,#select_mask').click(function(){
						$('#select_mask').hide();
						$('#select_picker').removeClass('selectUp').addClass('selectDown');
					});
				});
			},
			initSelectB:function(params){
				var config={
					selector:$('#select'),
					selectArray:new Array(),
					callback:null
				};
				$.extend(config, params);
				config.selector.click(function(event){
					event.stopPropagation();
					$('#select_mask,#select_picker').remove();
					$('body').append('<div id="select_mask"></div><div id="select_picker" class="selectUp"><div id="select_header"><div id="select_cancle"></div><div id="select_ok">完成</div></div><div id="select_body"><div id="select_top"></div><div id="select_fotter"></div></div></div>');
					$('#select_body').append('<div id="select_wrapper"><div><div class="m_select"></div><div class="m_select"></div><div class="m_select end_select"></div><div class="m_select"></div><div class="m_select"></div></div></div>');
					$('#select_wrapper').height(240);
					$(config.selectArray).each(function(){
						$('<div id="'+this.id+'" class="m_select">'+this.name+'</div>').insertBefore('.end_select');
					});
					var select_scroll=new iScroll('select_wrapper',{scrollbarClass: 'myScrollbar',bounce:false,snap: 'div'});
					var index=config.selector.html()=="" || config.selector.html()==null?0:config.selectArray.indexOf(config.selector.html());
					select_scroll.scrollTo(0,-index*40,0);
					$('#select_ok').click(function(){
						
						index=-select_scroll.y/40;
						if(config.callback){
							config.callback(config.selectArray[index]);
						}
						$('#select_cancle').click();
					});
					$('#select_cancle,#select_mask').click(function(){
						$('#select_mask').hide();
						$('#select_picker').removeClass('selectUp').addClass('selectDown');
					});
				});
			},
			bindding:function(conf){
				$('body').append('<div id="alert_mask"></div>'+
					'<div id="alert_box">'+
						'<div id="alert_title">商会会员微信绑定</div>'+
						'<div id="bind_phone"><input type="text" placeholder="请输入手机号码"/><div id="bind_sendCode">获取验证码</div></div>'+
						'<div id="bind_code"><input type="text" placeholder="请输入验证码"/><div id="bind_ok_btn">确定</div></div>'+
					'</div>');
				$('#alert_box').css('top',($(window).height()-$('#alert_box').height())/2-25+'px').addClass('bounceIn');
			},
	};
	
	module.exports = exports;
}); 